package boss.portal.repository;

import boss.portal.entity.logg.UserOptLoggerEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface UserOptLoggerRepository extends ElasticsearchRepository<UserOptLoggerEntity, String> {

    @Query("{\"bool\" : {\"must\" : {\"field\" : {\"content\" : \"?\"}}}}")
    Page<UserOptLoggerEntity> findByContent(String content, Pageable pageable);

    @Query("{\"bool\" : {\"must\" : {\"term\" : {\"firmId\" : \"?\"}}}}")
    Page<UserOptLoggerEntity> findByFirmId(String firmId, Pageable pageable);

    @Query("{\"bool\" : {\"must\" : {\"term\" : {\"operator\" : \"?\"}}}}")
    Page<UserOptLoggerEntity> findByOperator(String operator, Pageable pageable);

    @Query("{\"bool\" : {\"must\" : {\"term\" : {\"optModule\" : \"?\"}}}}")
    Page<UserOptLoggerEntity> findByOptModule(String optModule, Pageable pageable);

    @Query("{\"bool\" : {\"must\" : {\"term\" : {\"optType\" : \"?\"}}}}")
    Page<UserOptLoggerEntity> findByOptType(String optType, Pageable pageable);

}
